import  React from 'react'
import { Redirect, Route } from 'react-router';

export default class AuthRouterGuard extends React.Component {
    render () {
        const {component: Component, ...rest} = this.props
        return (
            <Route {...rest} render={props => {
                if (this.props.auth.isAuthor) {
                    return <Component {...props} />
                } else {
                    return <Redirect to='/home' />
                }
            }} />
        )
    }
}